<extend name="Public:Base" />
<block name="head">
    <link rel="stylesheet" href="/Public/ke/themes/default/default.css" />
	<script charset="utf-8" src="/Public/ke/kindeditor-min.js"></script>
	<script charset="utf-8" src="/Public/ke/lang/zh_CN.js"></script>
</block>
<block name="content">
	<div class="main-title">
		<h2><eq name="ACTION_NAME" value='add'>新增<else />编辑</eq>文章 [ <A HREF="__URL__">返回列表</A> ]</h2>
	</div>
	<FORM METHOD="POST" id="form1" class="form-horizontal" action="__URL__/<eq name="ACTION_NAME" value="add">insert<else />update</eq>" enctype="multipart/form-data">
		<div class="form-item cf">
			<label class="item-label">分   类：</label>
			<div class="controls"><html:select name="cid" options="CateList" selected="vo['cid']" />
			</div>
		</div>
		<div class="form-item cf">
			<label class="item-label">标题：<span class="check-tips"></span></label>
			<div class="controls">
				<input type="text" class="text input-large" id="title" name="title" value="{$vo.title}" datatype="*1-100" nullmsg="标题不能为空" errormsg="标题长度不能超过100个字">
			</div>
		</div>
		<div class="form-item cf">
			<label class="item-label">缩略图：</label>
			<div class="controls">
				<input type="text" class="text input-large" id="img" name="img" value="{$vo.img|default='Public/cover.jpg'}" /><button id="image1" class="btn" type="button">选择图片</button>
				<br>
				<!-- <INPUT TYPE="file" name="img" class="text input-large"  check='Require' warning="缩略图不能为空" > -->
				<img src="{$vo.img}" id="showImg" <eq name="vo.img" value=""> style="display:none;"</eq> />
			</div>
		</div>
		<div class="form-item cf">
			<label class="item-label">内容摘要：</label>
			<div class="controls">
				<label class="textarea">
					<textarea class="text input-large" NAME="abstruct" >{$vo.abstruct}</textarea>
				</label>
			</div>
		</div> 
		<div class="form-item cf">
			<label class="item-label">内   容：</label>
			<div class="controls">
				<label class="textarea">
					<textarea id="_editor" name="content" class="width:700px; height:400px;">{$vo.content|htmlspecialchars}</textarea>
                </label>
			</div>
		</div>
		<div class="form-item cf">
			<label class="item-label">标   签：</label>
			<div class="controls"><INPUT TYPE="text" class="text input-large" NAME="tags" value="{$vo.tags}">
			</div>
		</div>
		<div class="form-item cf">
			<label class="item-label">排   序：</label>
			<div class="controls"><INPUT TYPE="text" class="text input-large" NAME="sort" value="{$vo.sort|default=0}">
			</div>
		</div>
		<div class="form-item">
			<INPUT TYPE="hidden" name="id" value="{$vo.id}">
			<INPUT TYPE="hidden" name="jumpurl" value="{$Think.server.HTTP_REFERER}">
			<button type="submit" class="btn submit-btn ajax-post">确 定</button>
			<button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
		</div>
	</FORM>
	<script type="text/javascript">
	$(function(){
		var editor;
		KindEditor.ready(function(K) {
			editor = K.editor({
	            allowFileManager : true,
	            uploadJson : '/admin.php?s=User/keupload&thumb=300,200,true&from=artcile',
	            fileManagerJson : '/admin.php?s=User/file_manager'
	            
	        });
			var contenteditor = K.create('textarea[name="content"]', {
	            allowFileManager : true,
	            minHeight:320,
	            cssPath:'__PUBLIC__/ke/plugins/code/prettify.css',
	            uploadJson : '/admin.php?s=User/keupload',
	            fileManagerJson : '/admin.php?s=User/file_manager'
	            
	        });
			K('#image1').click(function() {
				editor.loadPlugin('image', function() {
					editor.plugin.imageDialog({
						imageUrl : K('#img').val(),
						clickFn : function(url, title, width, height, border, align) {
							K('#img').val(url);
							$('#showImg').attr('src',url).show();
							editor.hideDialog();
						}
					});
				});
			});
		});
		$('#form1').Validform({
			tiptype:function(msg,o,cssctl){
                if(!o.obj.is("form")){
                	var pele=o.obj.parents('.form-item');
                    var infoObj=pele.find(".check-tips");
                    if (!infoObj || infoObj.length==0){
                        pele.find(".item-label").append('<span class="check-tips"></span>');
                    }
                    infoObj=pele.find(".check-tips");
                    if(o.type==2){
                        infoObj.removeClass('error');
                        infoObj.hide();
                    }else{
                        infoObj.addClass('error');
                        infoObj.html(msg).show();
                    }
                }
            }
		});
	})
	</script>
</block>